package com.ulook.lookplanet.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.Nullable;

import com.ulook.lookplanet.R;
import com.ulook.lookplanet.base.WidgetData;
import com.ulook.lookplanet.data.model.TPlanet;

/**
 * 描述：
 *
 * @author L1998
 * @data 2021/5/12
 */
public class PlanetView extends LinearLayout implements WidgetData<TPlanet> {

    private Context context;
    private TPlanet planet;

    public PlanetView(Context context) {
        super(context);
        initPlanetView(context);
    }

    public PlanetView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        initPlanetView(context);
    }

    public PlanetView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        initPlanetView(context);
    }

    private void initPlanetView(Context context){
        this.context = context;
        LayoutInflater.from(context).inflate(R.layout.widget_planet_view, this, true);
    }

    @Override
    public void setWidgetData(TPlanet value) {
        this.planet = value;
        TextView name = findViewById(R.id.w_planet_name);
        TextView des = findViewById(R.id.w_planet_des);

        name.setText(planet.getName());
        des.setText(planet.getDes());
    }

    @Override
    public void setWidgetData(TPlanet value, int currUserID) {
        setWidgetData(value);
    }
}
